/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tictactoe;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
 *
 * @author Kevin O
 */
public class OutputPanel extends JPanel{
    
    DrawPanel draw_panel;
    JLabel turn_indicator;
    
    Game game;
    
    public OutputPanel(MouseListener ml, MouseMotionListener mml, Game g){
        setLayout(new BorderLayout());
        
        //Create the turn indicator and adds it the panel
        turn_indicator = new JLabel("Game in progress...");
        turn_indicator.setFont(new Font("SansSerif", Font.PLAIN, 18));
        turn_indicator.setHorizontalAlignment( SwingConstants.CENTER );
        add(turn_indicator, BorderLayout.NORTH);
        
        game = g;
        
        //Create the drawing panel and adds it to the panel
        draw_panel = new DrawPanel(g);
        draw_panel.addMouseListener(ml);
        draw_panel.addMouseMotionListener(mml);
        add(draw_panel, BorderLayout.CENTER);   
    }
    
    public void checkTurn(){
        if (game.winState() == GameStatus.Xwin)
            turn_indicator.setText("Player 1 wins!");
        else if (game.winState() == GameStatus.Owin)
            turn_indicator.setText("Player 2 wins!");
        else if (game.winState() == GameStatus.Draw)
            turn_indicator.setText("Game Over - Draw");
        else
            turn_indicator.setText("Game in progress...");
    }
    
}
